package ais.dcproject.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

import ais.dcproject.dao.DropListDao;

public class DropListDaoImpl implements DropListDao{
	private SessionFactory sessionFactory;
	
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public List queryAllDepartments() {
		Session session = sessionFactory.getCurrentSession();
		Query query = session.createQuery("from Department");
		return query.list();
	}

	public List queryAllSpecialsByDepartmentId(Integer departmentId) {
		Session session = sessionFactory.getCurrentSession();
		Query query = session.createQuery("from Special where departmentId = ?");
		query.setInteger(0, departmentId);
		return query.list();
	}

}
